<?php
$intPlaceId		= $objRequest->getParam('placeid', 0);
$strCookieKey	= 'plcmt' . $intPlaceId;
$intPage		= isset($_COOKIE[$strCookieKey]) ? $_COOKIE[$strCookieKey] : $objRequest->getParam('page',1);

$intLimit		= COMMENT_LIMIT;
$intOff			= (($intPage-1) * $intLimit);
$intTotal		= 0;
$strUrl			= HOST_VFRIEND . 'comment/placecmt?placeid=' . $intPlaceId . '&';
$strRefer		= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : LINK_NEWS;

if($objRequest->getParam('send',false))
{
	$strContent = $objRequest->getParam('pcontent', '');		
	$intError = $objPlace->addComment($AppUI->id, $intPlaceId, $strContent);
	if($intError > 0) {
		Vfriend_Function::setMsg($arrMessage[12]);
		Vfriend_Function::redirect($strRefer);
	}
}

$intTotal	 	= $objPlace->getCmtTotal($intPlaceId);
if($intTotal > $intLimit && !isset($_COOKIE[$strCookieKey])) {
	$intPage 	= ceil($intTotal/$intLimit);
	$intOff 	= ($intPage - 1) * $intLimit;	
}
if($intOff >= $intTotal && $intOff) $intOff = $intTotal - $intLimit;
$arrComment		= $objPlace->getCmtList($intPlaceId,$intOff,$intLimit);
$this->view->comments	= $arrComment;
$this->view->intTotal	= $intTotal;
$this->view->intOffset	= $intOff;
$this->view->intLimit	= $intLimit;
$this->view->intPage	= $intPage;
$this->view->strUrl		= $strUrl;
$this->view->intPlaceId = $intPlaceId;

?>
